﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.ComponentModel;

using LostLib.Win32;

namespace LostLib.Windows
{
	public static class ConsoleWindow
	{
		public static bool AttachToProcess(int processID)
		{
			return WindowsAPI.AttachConsole(processID);
		}

		public static Size FontSize
		{
			get
			{
				var output = WindowsAPI.GetStdHandle(StandardHandle.Output);
				ConsoleFontInfo fontInfo;
				if (!WindowsAPI.GetCurrentConsoleFont(output, false, out fontInfo))
					throw new Win32Exception();

				var size = WindowsAPI.GetConsoleFontSize(output, fontInfo.Font);
				return new Size { Width = size.Width, Height = size.Height };
			}
		}
	}

	partial class ScreenWindow
	{
		public bool IsConsole
		{
			get
			{
				return ClassName == "ConsoleWindowClass";
			}
		}
	}
}
